package com.foreknow.oop;

/**
 * 构造器的重载(overload)  在调用构造器的时候会根据传入的参数决定调用哪一个构造器
 * @author shkstart
 * @create 2021-07-23 13:14
 */
public class OverloadDemo {
    public OverloadDemo(){
        System.out.println("111111111111");

    }

    public OverloadDemo(String a){
        System.out.println(a);
    }
    public OverloadDemo(String a,int b){
        System.out.println(a+b);//字符串拼接
    }

    public int add(int a,int b){
        return  a+b;
    }
    public int add(int a,int b,int c){
        return  a+b+c;
    }
    public static void main(String[] args) {
        OverloadDemo overloadDemo=new OverloadDemo("1");
        OverloadDemo overloadDemo1=new OverloadDemo("1",2);
    }
}
